package com.mtsmda.bookjava7.chapter11.generics.animals;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class AnimalDoctor {

	private static List<Animal> animals = new ArrayList<Animal>();
	private static List<? extends Serializable> serializables = new ArrayList<>();

	public static void animalDoctor(List<Animal> animals) {
		for (Animal animal : animals) {
			animal.isAnimal();
		}
	}

	public static void animalDoctor2(List<? extends Animal> animals) {
		for (Animal animal : animals) {
			animal.isAnimal();
		}
	}

	public static void addAnimal(Animal animal) {
		animals.add(animal);
	}

	public static void showAnimals() {
		animalDoctor(animals);
	}

	public static void add(List<? extends Serializable> serializables) {
		AnimalDoctor.serializables = serializables;
	}

	public static void showSerializable(
			List<? extends Serializable> serializables) {
		for (Serializable serializable : serializables) {
			System.out.println(serializable.getClass().getCanonicalName());
		}
	}

	public static void animal(List<? extends Animal> animalDoctors) {
		if (animalDoctors != null && animalDoctors.size() > 0
				&& animalDoctors.get(0) != null) {
			animalDoctors.get(0).isAnimal();
		}
	}

	public static void dog(List<? extends Dog> animalDoctors) {
		if (animalDoctors != null && animalDoctors.size() > 0
				&& animalDoctors.get(0) != null) {
			animalDoctors.get(0).isAnimal();
		}
	}

	public static void dog2(List<? super Dog> animalDoctors) {
		if (animalDoctors != null && animalDoctors.size() > 0
				&& animalDoctors.get(0) != null) {
			System.out.println(animalDoctors.get(0).getClass()
					.getCanonicalName());
		}
	}

	public static void japanDog(List<? super JapanAziyaDog> animalDoctors) {
		if (animalDoctors != null && animalDoctors.size() > 0
				&& animalDoctors.get(0) != null) {
			System.out.println(animalDoctors.get(0).getClass()
					.getCanonicalName());
		}
	}

}